package com.epfresh.supplier.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.EmployEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by shenjie on 2017/9/13.
 */

public class EmployManageAdapter extends BaseAdapter {
    private  Context context;
    private ArrayList<EmployEntity> list;
    public EmployManageAdapter(Context context, ArrayList<EmployEntity> list){
        this.context=context;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView==null){
            holder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.list_item_employ,null,false);
            holder.name= (TextView) convertView.findViewById(R.id.name_tv);
            holder.phone= (TextView) convertView.findViewById(R.id.phone_tv);
            convertView.setTag(holder);
        }
        holder= (ViewHolder) convertView.getTag();
        holder.name.setText(list.get(position).getName());
        holder.phone.setText(list.get(position).getPhone());
        return convertView;
    }

    private class ViewHolder{
        TextView name,phone;
    }

    public ArrayList<EmployEntity> getList() {
        return list;
    }

    public void setList(ArrayList<EmployEntity> list) {
        this.list = list;
    }
}
